package com.puti.doctor.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.puti.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.puti.common.log.annotation.Log;
import com.puti.common.log.enums.BusinessType;
import com.puti.common.security.annotation.PreAuthorize;
import com.puti.doctor.domain.HospitalDoctorLevel;
import com.puti.doctor.service.IHospitalDoctorLevelService;
import com.puti.common.core.web.controller.BaseController;
import com.puti.common.core.web.domain.AjaxResult;
import com.puti.common.core.utils.poi.ExcelUtil;
import com.puti.common.core.web.page.TableDataInfo;

/**
 * 医院-医生-等级 医院-医生-等级Controller
 * 
 * @author puti
 * @date 2021-04-22
 */
@CrossOrigin
@RestController
@RequestMapping("/level")
public class HospitalDoctorLevelController extends BaseController
{
    @Autowired
    private IHospitalDoctorLevelService hospitalDoctorLevelService;

    /**
     * 查询医院-医生-等级 医院-医生-等级列表
     */
    @GetMapping("/list")
    public TableDataInfo list(@RequestBody HospitalDoctorLevel hospitalDoctorLevel)
    {
        startPage();
        List<HospitalDoctorLevel> list = hospitalDoctorLevelService.selectHospitalDoctorLevelList(hospitalDoctorLevel);
        return getDataTable(list);
    }
    //查询医院全部的等级
    @GetMapping("/findAll")
    public R findAll(){
        List<HospitalDoctorLevel> hospitalDoctorLevels = hospitalDoctorLevelService.selectHospitalDoctorLevelList(null);
        return R.ok(hospitalDoctorLevels,"查询成功");
    }
    /**
     * 导出医院-医生-等级 医院-医生-等级列表
     */
    @Log(title = "医院-医生-等级 医院-医生-等级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HospitalDoctorLevel hospitalDoctorLevel) throws IOException
    {
        List<HospitalDoctorLevel> list = hospitalDoctorLevelService.selectHospitalDoctorLevelList(hospitalDoctorLevel);
        ExcelUtil<HospitalDoctorLevel> util = new ExcelUtil<HospitalDoctorLevel>(HospitalDoctorLevel.class);
        util.exportExcel(response, list, "医院-医生-等级 医院-医生-等级数据");
    }

    /**
     * 获取医院-医生-等级 医院-医生-等级详细信息
     */
    @GetMapping(value = "/{doctorLevelId}")
    public AjaxResult getInfo(@PathVariable("doctorLevelId") Long doctorLevelId)
    {
        return AjaxResult.success(hospitalDoctorLevelService.selectHospitalDoctorLevelById(doctorLevelId));
    }

    /**
     * 新增医院-医生-等级 医院-医生-等级
     */
    @Log(title = "医院-医生-等级 医院-医生-等级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HospitalDoctorLevel hospitalDoctorLevel)
    {
        return toAjax(hospitalDoctorLevelService.insertHospitalDoctorLevel(hospitalDoctorLevel));
    }

    /**
     * 修改医院-医生-等级 医院-医生-等级
     */
    @Log(title = "医院-医生-等级 医院-医生-等级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalDoctorLevel hospitalDoctorLevel)
    {
        return toAjax(hospitalDoctorLevelService.updateHospitalDoctorLevel(hospitalDoctorLevel));
    }

    /**
     * 删除医院-医生-等级 医院-医生-等级
     */
    @Log(title = "医院-医生-等级 医院-医生-等级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{doctorLevelIds}")
    public AjaxResult remove(@PathVariable Long[] doctorLevelIds)
    {
        return toAjax(hospitalDoctorLevelService.deleteHospitalDoctorLevelByIds(doctorLevelIds));
    }
}
